<template>
  <div class="search-condition">
    <el-form>
      <el-row>
        <el-col :span="8">
          <el-form-item label="搜索条件" label-width="85px">
            <el-input v-model="keyword" placeholder="请输入搜索条件"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="16">
          <el-form-item label-width="5px">
            <el-button type="primary" @click="search">搜索</el-button>
            <el-button @click="add" v-if="addBtnShow">新增</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <save-dialog :dialogShow.sync="dialogShow" type="add" @success="successHandler"></save-dialog>
  </div>
</template>

<script>
import saveDialog from "../saveDialog";

export default {
  name: 'searchCondition',
  props: {
    addBtnShow: Boolean
  },
  data() {
    return {
      dialogShow: false,
      keyword: ``
    }
  },
  methods: {
    search() {
      //查询条件交给父组件去调接口
      this.$emit('search', { keyword: this.keyword });
    },
    add() {
      this.dialogShow = true;
    },
    successHandler() {
      this.$emit('search');
    }
  },
  components: {
    saveDialog
  }
}
</script>

<style lang="less" scoped>
@import "./index.less";
</style>
